import Vue from "vue";
import App from "./App.vue";
import router from "./router";

import "./assets/css/global.css";
Vue.config.productionTip = false;
//字体图标
import "./assets/fonts/iconfont.css";
// element
import "element-ui/lib/theme-chalk/index.css";
import { Button, Input } from "element-ui";
import { Message } from "element-ui";
import { Form, FormItem } from "element-ui";
Vue.use(Button);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Input);
Vue.prototype.$message = Message;

//axios
import axios from "axios";
//根路径
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/";
Vue.prototype.$http = axios;

//导航守卫
router.beforeEach((to, from, next) => {
  if (to.path == "/login") return next();
  const strToken = window.sessionStorage.getItem("token");
  console.log("strToken :>> ", strToken);
  if (!strToken) return next("/login");
  next();
});
new Vue({
  router,
  render: (h) => h(App),
}).$mount("#app");
